package com.lzc.tlmail.tlmailsearch.controller;

import com.lzc.common.utils.R;
import com.lzc.tlmail.tlmailsearch.service.MallSearchService;
import com.lzc.tlmail.tlmailsearch.vo.SearchParam;
import com.lzc.tlmail.tlmailsearch.vo.SearchResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;

import javax.servlet.http.HttpServletRequest;

/**
 * @author lzc
 * @create 2020-09-29 20:15
 */
@Controller
public class SearchController {

    @Autowired
    private MallSearchService mallSearchService;

    /**
     * 选择分类进行检索
     * @param searchParam
     * @param model
     * @return
     */
    @GetMapping("/list.html")
    public String list(SearchParam searchParam, Model model,HttpServletRequest request){
        searchParam.setQueryString(request.getQueryString());
        SearchResult searchList = mallSearchService.search(searchParam);
        model.addAttribute("searchList",searchList);
        return "list";
    }
}
